#include "weapons.h"

Weapons::Weapons()
{
    // 0 You don't have the weapon
    // 1 You have the wepeaon
    sword = 1;
    axe = 0;
    mace = 0;

    swordActive = true;
    axeActive = false;
    maceActive = false;

    sword_health = 100;
    axe_health = 0;
    mace_health = 0;
}

void Weapons::addWeapon(string type)
{
    if(type == "sword")
    {
        sword = 1;
        sword_health = 100;
        if(getActive() == "none") //checks to see of you have no weapson
            setActive("sword");    //if no weapons it makes the just added weapon active
    }
    if(type == "axe")
    {
        axe = 1;
        axe_health = 200;
        if(getActive() == "none")
            setActive("axe");
    }
    if(type == "mace")
    {
        mace = 1;
        mace_health = 300;
        if(getActive() == "none")
            setActive("mace");
    }
}

void Weapons::removeWeapon(string type)
{
    if(type == "sword")
    {
        sword = 0;
        sword_health = 0;
        if(swordActive)
        {
            swordActive = false;
            if(axe == 1)
                setActive("axe");
            else if (mace == 1)
                setActive("mace");
        }
    }
    else if(type == "axe")
    {
        axe = 0;
        axe_health = 0;
        if(axeActive)
        {
            axeActive = false;
            if(sword == 1)
                setActive("sword");
            else if (mace == 1)
                setActive("mace");
        }
    }
    else if(type == "mace")
    {
        mace = 0;
        mace_health = 0;
        if(maceActive)
        {
            maceActive = false;
            if(sword == 1)
                setActive("sword");
            else if (axe == 1)
                setActive("axe");
        }
    }
}

void Weapons::setActive(string type)
{   //setting and checking for sword
    if( type == "sword" && (sword !=0) )
        swordActive = true; //Sword is actvive weapon
    else
        cout << "You do not have the sword.";

    //Setting and checking for axe
    if(type == "axe" && axe!=0)
        axeActive = true; //Axe is actvive weapon
    else
        cout << "You do not have the axe.";

    //Setting and checking for mace
    if(type == "mace" && mace!=0)
        maceActive = true; //Mace is actvive weapon
    else
        cout << "You do not have the Mace.";
}

string Weapons::getActive()
{
    if(swordActive)
        return "sword";
    else if (axeActive)
        return "axe";
    else if (maceActive)
        return "mace";
    else
        return "none";
}

int Weapons::getAllWeapons()
{
    return 123;
}

void Weapons::setDamage(int damagedone)
{
    if(swordActive)
    {
        sword_health = sword_health - damagedone;

        if(sword_health <= 0)
            removeWeapon("sword");
    }
    else if(axeActive)
    {
        axe_health = axe_health - damagedone;

        if(axe_health <= 0)
            removeWeapon("axe");
    }
    else if(maceActive)
    {
        mace_health = mace_health - damagedone;

        if(mace_health <= 0)
            removeWeapon("mace");
    }
}

int Weapons::getHealth()
{
    return 0;
}

Weapons::~Weapons()
{

}

